package lesson.ch10;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@Service
public class AnnoDemo1 {
	@AutoRun
	public void fun1() {
		System.out.println("fun1 -- auto RUN") ;
	}
	public void fun2() {
		System.out.println("fun2 -- auto RUN") ;
	}
	@AutoRun
	public void fun3() {
		System.out.println("fun3 -- auto RUN") ;
	}
	public void fun4() {
		System.out.println("fun4 -- auto RUN") ;
	}
	@AutoRun
	public void fun5() {
		System.out.println("fun5 -- auto RUN") ;
	}
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		 Class cls = Class.forName("lesson.ch10.AnnoDemo1");
		 AnnoDemo1 obj = (AnnoDemo1) cls.newInstance();
		if (cls.isAnnotationPresent(Service.class)) {
			for(Method m:cls.getMethods()) {
				if (m.isAnnotationPresent(AutoRun.class)) m.invoke(obj); 
			}
		 }
	}
}
